function [sj_out, p_out] = new_eq(p_cf,mc_cf,theta2,ns,ind_market,x2,cf_salestax, delta, A1, QI,year)
sel_mrkt=ind_market(year>=2019);
% 
options = optimset('Algorithm','sqp','GradObj', ...
'off','GradCon','off','DerivativeCheck','off', 'maxiter', 4000,...
'MaxFunEvals', 1000000,'TolFun',1e-08,'TolX',1e-5);

p_out=p_cf;
p_2={};
v_c=getranddraw(length(theta2)-1, ns);
parfor ii=min(sel_mrkt):max(sel_mrkt)
    ii
    temp=find(ind_market==ii);
    p_cf_i=p_cf(temp);
    delta_i=delta(temp);
    mc_i=mc_cf(temp);
    A1_i=A1(temp,temp);
    x2_i=x2(temp,:);
    cf_salestax_i=cf_salestax(temp,:);
    tic
    [p_1,fval]=fmincon(@(p0)new_pr(p0,delta_i,mc_i,A1_i,x2_i,theta2,v_c,cf_salestax_i),p_cf_i,[], [], [], [], ...
    [],[],[], options);
    toc
    p_2{ii}=p_1;
end

for jj=min(sel_mrkt):max(sel_mrkt)
    temp2=find(ind_market==jj);
    p_out(temp2)=p_2{jj};
end

expmu1=expmu(theta2,v_c,x2,p_out);
sj_out=mktshares(delta,expmu1,QI,ind_market);

end% function computing counterfactual price equilibrium  

